<div class="dux-page-header am-cf">
    <div class="page-title">
        <a class="am-btn am-btn-primary" href="{url('index')}"> 导航列表</a>
    </div>
    <div class="page-action">
        <a class="am-btn am-btn-danger" href="javascript:location.reload();"><i class="am-icon-refresh"></i></a>
    </div>
</div>

<div class="dux-body">
    <div class="am-panel am-panel-default dux-panel">
        <div class="am-panel-hd">{$assignName}导航</div>
        <div class="am-panel-bd">
            <form class="am-form  am-form-horizontal dux-form" data-mango="form-bind" method="post">
                <fieldset>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航分组</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <div class="dux-form-content">{$groupInfo.name}</div>
                            <input type="hidden" name="group_id" value="{$groupId}">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">上级导航</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <select data-am-selected="{btnWidth: '100%'}" name="parent_id" required>
                                <option value="0">==顶级导航==</option>
                                <!--loop{(array)$navList as $vo}-->
                                <option <!--if{$vo.nav_id == $info.parent_id}--> selected <!--{/if}--> value="{$vo.nav_id}">{$vo.cname}</option>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航名称</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <input type="text" name="name" value="{$info.name}" placeholder="请输入导航名称" required>
                        </div>
                    </div>
                    <?php $info['type'] = isset($info['type']) ? $info['type'] : 1; ?>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航类型</label>

                        <div class="am-u-md-10 am-u-sm-12">
                            <div class="am-g" data-mango="form-change" data-class="type">
                                <label class="am-radio-inline">
                                    <!--if{$info['type']}-->
                                    <input name="type" value="1" checked="checked" type="radio">
                                    <!--{else}-->
                                    <input name="type" value="1" type="radio">
                                    <!--{/if}-->
                                    内部链接
                                </label>

                                <label class="am-radio-inline">
                                    <!--if{!$info['type']}-->
                                    <input name="type" checked="checked" value="0" type="radio">
                                    <!--{else}-->
                                    <input name="type" value="0" type="radio">
                                    <!--{/if}-->
                                    外部链接
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="am-form-group type type-0  <!--if{$info.type}--> dux-hide <!--{/if}-->">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">链接地址</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <input type="text" name="url" value="{$info.url}" placeholder="导航外部链接地址">
                        </div>
                    </div>
                    <div class="am-form-group <!--if{!$info.type}--> dux-hide <!--{/if}--> type type-1">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">内部链接</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <select name="model">
                                <!--loop{(array)$navApiList as $vo}-->
                                <optgroup label="{$vo.name}">
                                    <!--if{!empty($vo.list)}-->
                                    <!--loop{$vo.list as $v}-->
                                    <option <!--if{$vo.target . ':' . $v.class_id == $info.target . ':' . $info.target_id}--> selected <!--{/if}--> value="{$vo.target}:{$v.class_id}">{$v.cname}</option>
                                    <!--{/loop}-->
                                    <!--{/if}-->
                                </optgroup>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航排序</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <input type="number" name="sort" value="{$info.sort}" placeholder="导航排序,按照从小->大排序列表">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">封面图</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <div class="dux-flex-layout">
                                <div class="flex-auto am-padding-top-sm">

                                        <div class="am-input-group">
                                            <input class="am-form-field" name="image" id="image" value="{$info.image}"
                                                   placeholder="可选,上传导航封面图">
                                        <span class="am-input-group-btn">
                                            <button class="am-btn am-btn-default" type="button" data-mango="form-upload"
                                                    data-target="#image" data-type="jpg,png,bmp"
                                                    data-callback="imageUpload"><i
                                                    class="am-icon-upload"></i></button>
                                        </span>
                                        </div>
                                </div>
                                <div style="width: 170px;" class="am-text-right">
                                    <!--if{$info.image}-->
                                    <img src="{$info.image}" id="image-pic" alt="" height="50" width="150">
                                    <!--{else}-->
                                    <img src="__PUBLIC__/system/images/nopic-150-50.png" id="image-pic" alt="" height="50"
                                         width="150">
                                    <!--{/if}-->
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">副导航名称</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <input type="text" name="subname" value="{$info.subname}" placeholder="可选,副导航名称">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航关键词</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <input type="text" name="keyword" value="{$info.keyword}" placeholder="可选,导航关键词">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-md-2 am-u-sm-12 am-form-label">导航描述</label>
                        <div class="am-u-md-10 am-u-sm-12">
                            <textarea name="description" placeholder="可选,导航描述信息">{$info.description}</textarea>
                        </div>
                    </div>

                    <div class="am-form-group">
                        <div class="am-u-sm-offset-12 am-u-md-offset-2">
                            <input type="hidden" name="nav_id" value="{$info.nav_id}">
                            <button class="am-btn am-btn-primary" type="submit" disabled>保存</button>
                        </div>
                    </div>

                </fieldset>
            </form>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('table').find('thead input[type=checkbox]').change(function () {
            if ($(this).prop('checked')) {
                $(this).parents('table').find("[type='checkbox']").prop("checked", true);
            } else {
                $(this).parents('table').find("[type='checkbox']").prop("checked", false);
            }
        });
        $('table').find('.row').change(function () {
            if ($(this).prop('checked')) {
                $(this).parents('tr').find("[type='checkbox']").prop("checked", true);
            } else {
                $(this).parents('tr').find("[type='checkbox']").prop("checked", false);
            }
        });
    });
    window.imageUpload = function (data) {
        $('#image-pic').attr('src', data.url);
    }
</script>